package com.thinkgem.jeesite.modules.record.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.thinkgem.jeesite.common.persistence.Page;
import com.thinkgem.jeesite.common.service.CrudService;
import com.thinkgem.jeesite.modules.building.service.RoomService;
import com.thinkgem.jeesite.modules.record.dao.RecordDao;
import com.thinkgem.jeesite.modules.record.entity.Record;
import com.thinkgem.jeesite.modules.sys.utils.UserUtils;

@Service
@Transactional(readOnly = true)
public class RecordService extends CrudService<RecordDao, Record>{

	@Autowired
	RoomService roomService;
	@Autowired
	RecordDao recordDao;
	/**
	 * 找到自己的缴费记录
	 * */
	public Page<Record> findMyList(Page<Record> page ,Record record){
		record.setRoom(roomService.findRoomByOwnerId(UserUtils.getUser().getId()));
		record.setPage(page);
		page.setList(recordDao.findMyList(record));
		return page;
	}
	/**
	 * insert a record
	 * */
	@Transactional(readOnly = false)
	public void insertRecord(Record record){
		recordDao.insertRecord(record);
	}
}
